;; This code is taken from somewhere, I think from the GNU Guile mailing
;; list. Not mine.

;; https://www.gnu.org/software/guile/manual/html_node/Pipes.html

(system "diff -ua /tmp/file1 /tmp/file2 | wc -c")

(define (diffsize f1 f2)
  (receive (from to pids)
      (pipeline (list (list "/usr/bin/diff" "-ua" f1 f2)
                      (list "/usr/bin/wc" "-c")))
    (let ((rval (cons f2 (string->number
                          (string-delete #\newline
                                         (read-delimited " " from)))))
          (xvals (map (compose status:exit-val cdr waitpid) pids)))
      (close to)
      (close from)
      (format #t "Exit values: ~a\n" xvals)
      rval)))
